package org.ns.example;

import org.ns.learn.rpc.RpcServer;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

// @Configuration
public class ServerStartup implements ApplicationContextAware, InitializingBean {

    ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public void afterPropertiesSet() throws Exception {
        RpcServer rpcServer = new RpcServer(applicationContext);
        Thread thread = new Thread(()->{
            rpcServer.start(11111);
        });
        thread.start();
    }
}
